<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<script type="text/javascript">
	var num = 1,id=1;
	function addTitleType(){
		var score = parseInt($('#ss').numberspinner('getValue'));
		if(score<=0){
			alert("请输入正确的总分数!");
			return;
		}
		var b = true;
		var scoreNum = 0;
		$.each($('#titleTypeTd p'),function(i,p){
			var input = $(this).find('.easyui-numberspinner')[0];
			var value = $(input).val();
			if(value==''){
				alert("请输入题型占数!");
				b = false;
			}
			scoreNum += parseInt(value);
		});
		if(!b){
			return;
		}
		var lost = score - scoreNum;
		if(lost<=0){
			alert("没有分数可以添加题型！");
			return;
		}
		var str = '<p id="p'+id+'" style="margin: 10px">'+
					'<font>'+num+'</font>、'+
					'<select id="cc'+id+'" class="easyui-combobox" name="titleType"'+ 
					 'style="width:200px;height: 30px" data-options="'+
					 	'onSelect:function(record){'+
					 		'var titleType = record.value;'+
					 	'}'+
					 '">   '+
					    '<option value="sign">单选题</option>'+   
					    '<option value="muti">多选题</option>  '+ 
					    '<option selected value="is">判断题</option>   '+
					    '<option value="text">主观题</option>   '+
					    '<option value="input">填空题</option>   '+
					'</select>'+
					'占分:&nbsp;'+
					'<input id="cs+'+id+'" name="scoreCount" class="easyui-numberspinner" style="width:80px;height: 30px"'+   
					'required="required" data-options="min:1,max:'+lost+',editable:true">'+
				
					'<a href="#" onclick="removeTitleType('+id+')">移除</a>'+
				'</p>';
		$('#titleTypeTd').append(str);
		$.parser.parse('#p'+id);
		id++;
		num++;
	}
	function removeTitleType(id){
		$('#p'+id).remove();
		num = 1;
		$.each($('#titleTypeTd p'),function(i,p){
			var font = $(this).find('font')[0];
			$(font).html(num);
			num++;
		});
	}
</script>
	<form id="dataForm">
		<input type="hidden" id="titleType_" name="strDate"/>
		<table class="kv-table">
			<tbody>
				<tr>
					<td class="kv-label">出卷人</td>
					<td colspan="3" class="kv-content">
					<input type="hidden" name="loginName" value="${eu.loginName }">
					<input class="easyui-textbox" readonly value="${eu.name }"
						style="height: 28px;line-height: 24px;width:200px">
					
					</td>
				</tr>
				
				<tr>
					<td class="kv-label">试卷名称</td>
					<td colspan="3" class="kv-content">
						<input required="required" class="easyui-textbox" name="title"
						style="height: 28px;line-height: 24px;width:500px">
					</td>
				</tr>
				<tr>
					<td class="kv-label">分数</td>
					<td class="kv-content" colspan="3">
						<input id="ss" value="1" name="score" class="easyui-numberspinner" style="width:80px;height: 30px"   
        				required="required" data-options="min:1,max:300,editable:true">
        				<a href="#" plain=false class="easyui-linkbutton" 
        				 onclick="javascript:$('#ss').numberspinner('setValue',100)">100</a>	
        				<a href="#" plain=false class="easyui-linkbutton" 
        				 onclick="javascript:$('#ss').numberspinner('setValue',120)">120</a>	
        				<a href="#" plain=false class="easyui-linkbutton" 
        				 onclick="javascript:$('#ss').numberspinner('setValue',150)">150</a>	
        				<a href="#" plain=false class="easyui-linkbutton" 
        				 onclick="javascript:$('#ss').numberspinner('setValue',300)">300</a>	
					</td>
				</tr>
				<tr id="titleTypeTr">
					<td class="kv-label">
						<a href="#" plain=false class="easyui-linkbutton" 
						iconCls="icon-add" onclick="addTitleType()">题型</a>
					</td>
					<td colspan="3" class="kv-content" id="titleTypeTd">
					</td>
				</tr>
				<tr>
					<td class="kv-label">科目</td>
					<td id="fileTd" class="kv-content" colspan="3">
						<select id="cc1" class="easyui-combobox" 
						name="lesson" style="width:200px;height: 30px;">   
						    <option value="java">Java</option>   
						    <option value=".net">.net</option>   
						    <option value="php">php</option>   
						    <option value="android">安卓</option>   
						    <option value="ios">苹果</option>   
						</select> 
					</td>
				</tr>
				<tr>
					<td class="kv-label">年份</td>
					<td colspan="3" class="kv-content" id="answerTd">
						<input id="ss1" name="year" class="easyui-numberspinner" style="width:80px;height: 30px"   
        				required="required" data-options="min:2000,max:2019,editable:false">	
					</td>
				</tr>
			</tbody>
		</table>
	</form>
</body>
</html>